package com.photoeditor.demo.statistics;

import android.content.Context;
import android.text.TextUtils;

import com.common.base.ComponentContext;
import com.photoeditor.R;
import com.photoeditor.demo.model.store.module.StoreOnlineManager;

/**
 * Created by Lai on 2018/1/30 0030.
 */

public class NotifyStoreUpdateStatisticBean {
    public String pkgName;
    public int type;
    String statisticName;

    public NotifyStoreUpdateStatisticBean(String pkgName, String name, int type) {
        this.pkgName = pkgName;
        this.type = type;
        statisticName = getStatisticName(type, name);
    }

    public void statisticDownload(String pkgName) {
        if(check(pkgName)) {
            StatisticsUtils.statisticsNotificationContentUpdateDownload(statisticName);
        }
    }

    public void statisticApply(String pkgName) {
        if(check(pkgName)) {
            StatisticsUtils.statisticsNotificationContentUpdateApply(statisticName);
        }
    }

    public void statisticSave(String pkgName) {
        if(check(pkgName)) {
            StatisticsUtils.statisticsNotificationContentUpdateSave(statisticName);
        }
    }

    public void statisticShare(String share) {
        if(check(pkgName)) {
            StatisticsUtils.statisticsNotificationContentUpdateShare(statisticName, share);
        }
    }

    private boolean check(String name) {
        if(!TextUtils.isEmpty(pkgName) && !TextUtils.isEmpty(statisticName) && pkgName.equals(name)) {
            return true;
        }
        return false;
    }

    private String getStatisticName(int type, String name) {
        String ret = "";
        Context context = ComponentContext.getContext();
        if (type == StoreOnlineManager.STORE_FUNC_TYPE_FILTER) {
            ret = context.getString(R.string.notify_store_update_filter_title, name);
        }
        return ret;
    }
}
